package com.citcc.api.netty.utils;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.citcc.api.netty.bean.ConsuMessage;
import com.citcc.api.netty.server.ServerToClient;
import com.citcc.api.netty.utils.HexUtil;

/**
 * @author liyachong
 * @date 2019/4/5
 * @time 15:58
 */
public class CommandUtil {
    private static Logger log = LoggerFactory.getLogger(CommandUtil.class);

   
    public static int cmd(String deviceNo,String source,String phone, long time) {
        log.info("终端号=="+deviceNo+"-->枪号="+source+"-->手机号:"+phone+"-->充电时间m:"+time);
        ConsuMessage m = new ConsuMessage();
        m.setDeviceNo(Long.parseLong(deviceNo));
        m.setSource(Integer.parseInt(source));
        m.setPhone(phone);
        m.setMode("2");//充电模式 0.自动充电 1.金额模式 2.时间模式 3电量模式
        m.setTime(time);//单位秒
        int i = new ServerToClient().startCmd(m);
       return i;
    }
    
    public static int tcmd(String deviceNo,String source,String phone) {
    	log.info("终端号=="+deviceNo+"-->枪号="+source+"-->手机号:"+phone);
    	ConsuMessage m = new ConsuMessage();
        m.setDeviceNo(Long.parseLong(deviceNo));
        m.setSource(Integer.parseInt(source));
        m.setPhone(phone);
        int i = new ServerToClient().stopCmd(m);
        return i;

    }
    
    public static void main(String[] args) {
		long l = 2826509056L;
		String s ="a8791b";
		String ss = new String(HexUtil.getBytesWithLengthAfter(4, s.getBytes()));
		System.out.println("s==="+ss);
	}


}
